package me.ingxin.android.keyboard.entry


/**
 * Created by ingxin on 2023/2/3
 * 键盘按键
 * @param label 显示文字
 * @param code ASCII
 * @param left 按键在view上的left坐标
 * @param top 按键在view上的top坐标
 * @param right 按键在view上的right坐标
 * @param bottom 按键在view上的bottom坐标
 */
data class Key(
    var left: Float,
    var top: Float,
    var right: Float,
    var bottom: Float,
    var code: Int,
    var label: String?
) {

    /**按键是否处于被按压状态*/
    var pressed = false

    fun getDrawableState(): IntArray {
        return if (pressed) {
            intArrayOf(android.R.attr.state_pressed)
        } else {
            intArrayOf(-android.R.attr.state_pressed)
        }
    }

    fun getWidth(): Float {
        return right - left
    }

    fun getHeight(): Float {
        return bottom - top
    }

    companion object {

        /**切换成大写*/
        const val CODE_SHIFT_UP = -1

        /**切换成小写*/
        const val CODE_SHIFT_LOWER = -2

        /**删除*/
        const val CODE_DELETE = -3

        /**切换成数字键盘*/
        const val CODE_NUMBER = -4

        /**切换成符号键盘*/
        const val CODE_SYMBOL = -5

        /**切换成字母键盘*/
        const val CODE_LETTER = -6

        /**隐藏关闭键盘*/
        const val CODE_HIDE = -7

    }


}
